﻿using FPDAM.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;

namespace TestModule
{
    /// <summary>
    /// 测试基础算法类
    /// </summary>
    public partial class TestBaseMethod : ITestInterface
    {
        #region 绘图接口实现
        private Dictionary<int, object> _curveSet = new Dictionary<int, object>();
        private List<Curve> _curves = new List<Curve>();
        private List<CurveSegment> _curveSegs = new List<CurveSegment>();
        private List<Point3D> _points = new List<Point3D>();
        private List<string> _testFunction = new List<string>();

        public Dictionary<int, object> GetCurveSet()
        {
            int i = 0;
            foreach (var item in this._curves)
            {
                this._curveSet.Add(i, item);
                i++;
            }

            foreach (var item in this._curveSegs)
            {
                this._curveSet.Add(i, item);
                i++;
            }

            foreach (var item in this._points)
            {
                this._curveSet.Add(i, item);
                i++;
            }

            return this._curveSet;
        }

        public TestBaseMethod()
        {
            if (this._testFunction.Count != 0)
                this._testFunction.Clear();

            RegisteFunctions();
            RunTestFunction();
        }

        private void RunTestFunction()
        {
            Assembly assembly = Assembly.GetExecutingAssembly();
            Type type = this.GetType();
            foreach (string item in this._testFunction)
            {
                MethodInfo method = type.GetMethod(item);
                method.Invoke(this, null);
            }
        }

        private void RegisteFunction(string functionName)
        {
            this._testFunction.Add(functionName);
        }
        #endregion
    }
}
